package com.smallmanager.util;

import java.io.FileInputStream;
import java.io.FileOutputStream;

import org.apache.http.util.EncodingUtils;

public class FileUtil {
	//write SDCard
    public static void writeFileSdcardFile(String fileName, String writeStr) {
        try {
            
            FileOutputStream fout = new FileOutputStream(fileName);
            byte[] bytes = writeStr.getBytes();
            
            fout.write(bytes);
            fout.close();
            
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    
    //read SDCard
    public static String readFileSdcardFile(String fileName) {
        String res = "";
        try {
            
            FileInputStream fin = new FileInputStream(fileName);
            int length = fin.available();
            
            byte[] buffer = new byte[length];
            fin.read(buffer);
            
            res = EncodingUtils.getString(buffer, "UTF-8");
            
            fin.close();
            
        } catch (Exception e) {
            e.printStackTrace();
        }
        return res;
    }
}
